/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Heinz Hernandez
 */
@Entity
@Table(name = "appointment")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Appointment.findAll", query = "SELECT a FROM Appointment a"),
    @NamedQuery(name = "Appointment.findAppoSumByRecord", query = "SELECT SUM(a.appoCharge) FROM Appointment a WHERE a.recId = :recId"),
    @NamedQuery(name = "Appointment.findByAppoId", query = "SELECT a FROM Appointment a WHERE a.appoId = :appoId"),
    @NamedQuery(name = "Appointment.findByRecId", query = "SELECT a FROM Appointment a WHERE a.recId = :recId"),
    @NamedQuery(name = "Appointment.findByAppoDate", query = "SELECT a FROM Appointment a WHERE a.appoDate = :appoDate"),
    @NamedQuery(name = "Appointment.findByAppoCharge", query = "SELECT a FROM Appointment a WHERE a.appoCharge = :appoCharge"),
    @NamedQuery(name = "Appointment.findByAppoNotes", query = "SELECT a FROM Appointment a WHERE a.appoNotes = :appoNotes")})
public class Appointment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "APPO_ID")
    private Long appoId;
    @Basic(optional = false)
    @Column(name = "APPO_DATE")
    @Temporal(TemporalType.DATE)
    private Date appoDate;
    @Basic(optional = false)
    @Column(name = "APPO_CHARGE")
    private int appoCharge;
    @Basic(optional = false)
    @Column(name = "APPO_NOTES")
    private String appoNotes;
    @JoinColumn(name = "REC_ID", referencedColumnName = "REC_ID")
    @ManyToOne
    private Record recId;
    @JoinColumn(name = "PER_ID", referencedColumnName = "PER_ID")
    @ManyToOne
    private Person perId;

    public Appointment() {
    }

    public Appointment(Long appoId) {
        this.appoId = appoId;
    }

    public Appointment(Long appoId, Date appoDate, int appoCharge, String appoNotes) {
        this.appoId = appoId;
        this.appoDate = appoDate;
        this.appoCharge = appoCharge;
        this.appoNotes = appoNotes;
    }

    public Long getAppoId() {
        return appoId;
    }

    public void setAppoId(Long appoId) {
        this.appoId = appoId;
    }

    public Date getAppoDate() {
        return appoDate;
    }

    public void setAppoDate(Date appoDate) {
        this.appoDate = appoDate;
    }

    public int getAppoCharge() {
        return appoCharge;
    }

    public void setAppoCharge(int appoCharge) {
        this.appoCharge = appoCharge;
    }

    public String getAppoNotes() {
        return appoNotes;
    }

    public void setAppoNotes(String appoNotes) {
        this.appoNotes = appoNotes;
    }

    public Record getRecId() {
        return recId;
    }

    public void setRecId(Record recId) {
        this.recId = recId;
    }

    public Person getPerId() {
        return perId;
    }

    public void setPerId(Person perId) {
        this.perId = perId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (appoId != null ? appoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Appointment)) {
            return false;
        }
        Appointment other = (Appointment) object;
        if ((this.appoId == null && other.appoId != null) || (this.appoId != null && !this.appoId.equals(other.appoId))) {
            return false;
        }
        return true;
    }

    @Override
//    public String toString() {
//        return "Entities.Appointment[ appoId=" + appoId + " ]";
//    }
//    
    public String toString() {
        return "DATE:  " + appoDate + "  CHARGE: " + appoCharge + "  NOTES: " + appoNotes;
    }
    
}
